package Chapter5;

class TicketWindow2 implements Runnable{
	private int tickets =100;
	public void run() {
		while (true) {
			if (tickets>0) {
				Thread th=Thread.currentThread();
				String th_name=th.getName();
				System.out.println(th_name+"正在发售第"+tickets--+"张票");
			}
		}
	}
}
public class Example05 {
	public static void main(String[] args) {
		TicketWindow2 tw=new TicketWindow2();
		new Thread(tw,"window1").start();
		new Thread(tw,"window2").start();
		new Thread(tw,"window3").start();
		new Thread(tw,"window4").start();
	}
}
